//
//  BusinessViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/9/8.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//


#import "BusinessActDetailViewController.h"
#import "RDVTabBarController.h"
#import "RDVTabBarItem.h"
#import "CycleScrollView.h"
#import "BusinessCell.h"
#import "HttpRequest.h"
#import "UIButton+WebCache.h"
#import "HAODEsingleton.h"

#import "TheLoginViewController.h"
#import "huiyuandengjiViewController.h"
#import "GetProductListViewController.h"
#import "GenerateQRCodeViewController.h"
#import "ScanViewController.h"
#import "ShopcatListViewController.h"
#import "MJRefresh.h"
#import "orderListsViewController.h"
#import "myJobViewController.h"
#import "ActListViewController.h"
#import "SelectTheCertificationViewController.h"
#import "CaseListViewController.h"
#import "ServiceListViewController.h"
#import "RefundListViewController.h"
#import "RollingTitleBtn.h"
#import "ComposeView.h"
#import "actView.h"
#import "proview.h"
#import "casusView.h"
#import "CaseDetailViewController.h"
#import "GetProductDetailViewController.h"
#import "ACETelPrompt.h"
#import <MapKit/MapKit.h>
#import "MapViewControllers.h"
#import "UMSocial.h"
#import "editorActViewController.h"
@interface BusinessActDetailViewController ()<CLLocationManagerDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UIScrollViewDelegate,UMSocialUIDelegate>
@property (nonatomic, unsafe_unretained) NSInteger currentIndex;
@property(nonatomic ,strong)NSDictionary*myDic;
@property(nonatomic, strong) RollingTitleBtn *notice;
@property(nonatomic,strong)   NSString*shareUrl;
@property(nonatomic,strong)   NSString*shuoming;
@end

@implementation BusinessActDetailViewController
{
    HAODEsingleton *commdity;
    CycleScrollView *mainScorllView;
    UIScrollView*mainScroll;
    UIScrollView*mainScroll1;
    NSMutableArray *ImageUrl1;
    NSMutableArray*LinkType;
    NSMutableArray*LinkCode;
    NSTimer *timess;
    UILabel*gonggao;
    NSArray*gonggaoarry;
    NSMutableArray *selectArray;//选择的
    NSMutableArray *Array;//选择的
    MJRefreshHeaderView* _header;
    MJRefreshFooterView* _footer;
    UIView*addView;
    BOOL saveAccount;
    int currentCount;
    UILabel*label;
    UIView*view;
    NSDate* time;
    UILabel *timeLabel;
    UIView*fengxiangview;
    UIButton* quxiao;
    UIScrollView*fengxiangScroll;
    NSMutableArray*imagearrays;
    NSMutableArray*imageUrlarrays;
}
@synthesize alt = alt;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"";
        
        
    }
    return self;
}



-(void)BackAction:(UIButton *)sender{
    
    
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden=NO;
    
    [[self rdv_tabBarController] setTabBarHidden:YES];
    
       UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    
    UIButton*editor = [[UIButton alloc] initWithFrame:CGRectMake(0, 0.0, 30, 30)];
    [editor setImage:[UIImage imageNamed:@"fenxiang"] forState:UIControlStateNormal];
    [editor addTarget:self action:@selector(fenxiangss:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton*editor1 = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0, 30, 30)];
    [editor1 setImage:[UIImage imageNamed:@"bianji"] forState:UIControlStateNormal];
    [editor1 addTarget:self action:@selector(editor:) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:editor];
    UIBarButtonItem* myBtnBtn1 = [[UIBarButtonItem alloc] initWithCustomView:editor1];
    
    NSArray *buttonArray = [[NSArray alloc]initWithObjects:myBtnBtn1,myBtnBtn, nil];
    self.navigationItem.rightBarButtonItems = buttonArray;
    
//    
//}
//
//-(void)viewDidLoad{
//    
//    [super viewDidLoad];
    self.title = @"活动详情";
 
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     backColor,
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];

    commdity =[HAODEsingleton shared];
    [mainScroll removeFromSuperview];
    mainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, ScreenWidth,ScreenHeight)];
    mainScroll.delegate = self;
    mainScroll.userInteractionEnabled = YES;
    mainScroll.scrollEnabled = YES;
    mainScroll.showsVerticalScrollIndicator = FALSE;
    mainScroll.showsHorizontalScrollIndicator = FALSE;
    
    [self .view addSubview:mainScroll];
    
    imagearrays=[[NSMutableArray alloc]init];
   
    imageUrlarrays=[[NSMutableArray alloc]init];
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:commdity.orderId forKey:@"actID"];

    
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    
    
    [HttpRequest requestData:@"Business/Act/Detail" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                commdity.Dict=severDataDict.dataDict;
                commdity.actTypeCode=[severDataDict.dataDict objectForKey:@"actTypeCode"];
                commdity.content=[severDataDict.dataDict objectForKey:@"actType"];
                UIImageView*image=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 210)];
                [image setImageWithURL:[severDataDict.dataDict objectForKey:@"imageUrlFull"] placeholderImage:nil];
                 [image setContentMode:UIViewContentModeScaleToFill];
                [mainScroll addSubview:image];
                
            
                view=[[UIView alloc]initWithFrame:CGRectMake(0,210, ScreenWidth, ScreenHeight)];
                view.backgroundColor=[UIColor whiteColor];
                [mainScroll addSubview:view];
                
                UIImageView *_xianview = [[UIImageView alloc]initWithFrame:CGRectMake(15,105-0.5, ScreenWidth-30, 0.5)];
                _xianview.image=[UIImage imageNamed:@"hengxian"];
                [view addSubview:_xianview];
                commdity.endDate=[severDataDict.dataDict objectForKey:@"endDate"];
                NSTimer *timer1 = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
                UIButton * timebtn=[[UIButton alloc]initWithFrame:CGRectMake(15, 15, 13, 13)];
                [timebtn setImage:[UIImage imageNamed:@"daojishi"] forState:UIControlStateNormal];
                [view addSubview:timebtn];
//                UILabel* end=[[UILabel alloc]initWithFrame:CGRectMake(timebtn.right+3, 14,18, 14)];
//                end.text=@"剩";
//                end.font = [UIFont systemFontOfSize:14];
//                end.textColor=shenhuicolor;
//                [view addSubview:end];
                
                timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(timebtn.right+3, 14, 170,14)];
                timeLabel.font = [UIFont systemFontOfSize:14];
                timeLabel.textAlignment=NSTextAlignmentLeft;
               
             
                [view addSubview:timeLabel];
                
                
                
                
                UIButton*lijibaoming = [[UIButton alloc]init];
                lijibaoming.frame = CGRectMake(ScreenWidth-75,20,60, 30);
                [lijibaoming  setTitle:@"立即报名" forState:UIControlStateNormal];
                [lijibaoming setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                lijibaoming.titleLabel.font =[UIFont systemFontOfSize:13];
                lijibaoming.layer.borderColor = hongsecolor.CGColor;
               
                [lijibaoming.layer setCornerRadius:3.0]; //设置矩圆角半径
                [lijibaoming.layer setBorderWidth:0.5];   //边框宽
                lijibaoming.backgroundColor=hongsecolor;
                [view addSubview:lijibaoming];

                
                for (NSDictionary *dic in [severDataDict.dataDict valueForKey:@"imageList"]) {
                 
                    [self getImageFromURL:[dic objectForKey:@"imageUrlFull"]];
                    [self getImageFromURLs:[dic objectForKey:@"imageUrl"]];
                }
                if ([[severDataDict.dataDict valueForKey:@"imageList"]count]==0) {
                    commdity.imageUrlFullarr=nil;
                    commdity.imageUrls=nil;
                }
                
                
             
                
                UILabel*acttitle=[[UILabel alloc]initWithFrame:CGRectMake(15, 55, 250, 16)];
                acttitle.text=[severDataDict.dataDict objectForKey:@"actName"];
                acttitle.textColor=[UIColor blackColor];
                acttitle.font=[UIFont systemFontOfSize:16];
                [view addSubview:acttitle];
                UILabel*leixing=[[UILabel alloc]initWithFrame:CGRectMake(15, 80, 250, 14)];
                leixing.text=[NSString stringWithFormat:@"%@ %@",  @"活动类型",[severDataDict.dataDict objectForKey:@"actType"]];
                leixing.textColor=shenhuicolor;
                leixing.font=[UIFont systemFontOfSize:14];
                NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ %@",  @"活动类型",[severDataDict.dataDict objectForKey:@"actType"]]];
                
                [AttributedStr addAttribute:NSFontAttributeName
                 
                                      value:[UIFont systemFontOfSize:14]
                 
                                      range:NSMakeRange(0, 4)];
                
                [AttributedStr addAttribute:NSForegroundColorAttributeName
                 
                                      value:zhonghuiColor
                 
                                      range:NSMakeRange(0, 4)];
                
                
                leixing.attributedText = AttributedStr;
                [view addSubview:leixing];
                
                
                UILabel*shu=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-70, 65, 50, 14)];
                shu.text=[ NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"joinCount"]];
                shu.textAlignment=NSTextAlignmentCenter;
                shu.textColor=shenhuicolor;
                shu.font=[UIFont systemFontOfSize:13];
               
                [view addSubview:shu];
                UILabel*baoming=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-70, 85, 50, 14)];
                baoming.text=@"已报名";
                baoming.textAlignment=NSTextAlignmentCenter;
                baoming.textColor=zhonghuiColor;
                baoming.font=[UIFont systemFontOfSize:12];
               
                [view addSubview:baoming];
                
             
                UIButton*addressImage1 = [[UIButton alloc]init];
                addressImage1.frame = CGRectMake(20,120,20, 20);
                [addressImage1 setImage:[UIImage imageNamed:@"daohangs"] forState:UIControlStateNormal];
                [view addSubview:addressImage1];
                UILabel*address1=[[UILabel alloc]initWithFrame:CGRectMake(50, 105, ScreenWidth-40, 50)];
                address1.text=[NSString stringWithFormat:@"%@%@", [severDataDict.dataDict objectForKey:@"actRegion"], [severDataDict.dataDict objectForKey:@"actAddress"]];
                address1.textColor=shenhuicolor;
                address1.numberOfLines=0;
                address1.font=[UIFont systemFontOfSize:15];
                [view addSubview:address1];
                UIButton*jiantouBtnjiada11 = [[UIButton alloc]init];
                jiantouBtnjiada11.frame = CGRectMake(ScreenWidth/2,105,ScreenWidth, 50);
                [jiantouBtnjiada11 addTarget:self action:@selector(shanghubuttonimage:) forControlEvents:UIControlEventTouchUpInside];
                 jiantouBtnjiada11.tag=302;
                [view addSubview:jiantouBtnjiada11];
                UIButton*jiantouBtn11 = [[UIButton alloc]init];
                jiantouBtn11.frame = CGRectMake(ScreenWidth-25,105+20,8, 13);
                [jiantouBtn11 setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
                [jiantouBtn11 addTarget:self action:@selector(shanghubuttonimage:) forControlEvents:UIControlEventTouchUpInside];
                 jiantouBtn11.tag=302;
                [view addSubview:jiantouBtn11];


                
                UIView*diseview=[[UIView alloc]initWithFrame:CGRectMake(0, 150, ScreenWidth, 10)];
                diseview.backgroundColor=zuiqianhuicolor;
                diseview.layer.borderColor = qianhuicolor.CGColor;
                [diseview.layer setBorderWidth:0.35];   //边
                [view addSubview:diseview];
                
 
                UIView*view1=[[UIView alloc]initWithFrame:CGRectMake(0,160, ScreenWidth, 140)];
                view1.backgroundColor=[UIColor whiteColor];
                [view addSubview:view1];
                
                UIView*diseview1=[[UIView alloc]initWithFrame:CGRectMake(0, 300, ScreenWidth, 10)];
                diseview1.backgroundColor=zuiqianhuicolor;
                diseview1.layer.borderColor = qianhuicolor.CGColor;
                [diseview1.layer setBorderWidth:0.35];   //边
                [view addSubview:diseview1];

                
                
                UILabel*companyName=[[UILabel alloc]initWithFrame:CGRectMake(90, 20, ScreenWidth-40, 16)];
                companyName.text=[[severDataDict.dataDict objectForKey:@"companyBaseInfo"] objectForKey:@"companyName"];
                companyName.textColor=[UIColor blackColor];
                companyName.font=[UIFont systemFontOfSize:16];
                [view1 addSubview:companyName];
                
                
                
                UILabel*renzheng=[[UILabel alloc]initWithFrame:CGRectMake(90, 45, 50, 14)];
                renzheng.text=@"物管认证";
                renzheng.textAlignment=NSTextAlignmentCenter;
                renzheng.textColor=[UIColor whiteColor];
                renzheng.font=[UIFont systemFontOfSize:11];
                renzheng.backgroundColor=luseColor;
                [view1 addSubview:renzheng];
                
                UILabel*renzheng1=[[UILabel alloc]initWithFrame:CGRectMake(150, 45, 50, 14)];
                renzheng1.text=@"经营认证";
                renzheng1.textAlignment=NSTextAlignmentCenter;
                renzheng1.textColor=[UIColor whiteColor];
                renzheng1.font=[UIFont systemFontOfSize:11];
                renzheng1.backgroundColor=luseColor;
                [view1 addSubview:renzheng1];
                UILabel*zhuying1=[[UILabel alloc]initWithFrame:CGRectMake(90, renzheng1.bottom, ScreenWidth-90, 30)];
                
                zhuying1.text=[NSString stringWithFormat:@"主营 %@  ",  [[severDataDict.dataDict objectForKey:@"companyBaseInfo"] objectForKey:@"businessType"]];
                zhuying1.textColor=shenhuicolor;
                zhuying1.font=[UIFont systemFontOfSize:13];
                NSMutableAttributedString *AttributedStr1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"主营 %@  ",  [[severDataDict.dataDict objectForKey:@"companyBaseInfo"] objectForKey:@"businessType"]]];
                
                [AttributedStr1 addAttribute:NSFontAttributeName
                 
                                       value:[UIFont systemFontOfSize:13.0]
                 
                                       range:NSMakeRange(0, 3)];
                
                [AttributedStr1 addAttribute:NSForegroundColorAttributeName
                 
                                       value:zhonghuiColor
                 
                                       range:NSMakeRange(0, 3)];
                
                
                zhuying1.attributedText = AttributedStr1;

                [view1 addSubview:zhuying1];
                

                UILabel*line1=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/2, 100, 0.35, 30)];
                line1.backgroundColor=qianhuicolor;
                [view1 addSubview:line1];
                UIButton* imageView = [[UIButton alloc]initWithFrame:CGRectMake(15, 10, 140/2, 140/2)];
                imageView.layer.masksToBounds = YES;
                imageView.backgroundColor=zuiqianhuicolor;
                imageView.layer.cornerRadius = 140/2/2;
                [imageView setImageWithURL:[NSURL URLWithString:[[severDataDict.dataDict objectForKey:@"companyBaseInfo"]objectForKey:@"companyImgUrlFull"]] placeholderImage:[UIImage imageNamed:@"touxiang"]];
                    imageView.layer.borderColor = zuiqianhuicolor.CGColor;
                    imageView.layer.borderWidth = 2;
                    imageView.contentMode = UIViewContentModeScaleToFill;
                    [view1 addSubview:imageView];
 
             
               commdity.adress=[severDataDict.dataDict objectForKey:@"actAddress"];

                
                UIButton*telImage1 = [[UIButton alloc]init];
                telImage1.frame = CGRectMake(50,105,20, 20);
                [telImage1 setImage:[UIImage imageNamed:@"dianhuasss"] forState:UIControlStateNormal];
                [view1 addSubview:telImage1];
                UILabel*tel1=[[UILabel alloc]initWithFrame:CGRectMake(60, 90, ScreenWidth/2-70, 50)];
                tel1.text=[NSString stringWithFormat:@"%@", @"电话联系"];
                tel1.textColor=shenhuicolor;
                tel1.numberOfLines=0;
                tel1.textAlignment=NSTextAlignmentCenter;
                tel1.font=[UIFont systemFontOfSize:15];
                [view1 addSubview:tel1];
                UIButton*jiantouBtnjiada = [[UIButton alloc]init];
                jiantouBtnjiada.frame = CGRectMake(0,90,ScreenWidth/2, 50);
                [jiantouBtnjiada addTarget:self action:@selector(shanghubuttonimage:) forControlEvents:UIControlEventTouchUpInside];
                jiantouBtnjiada.tag=301;
                [view1 addSubview:jiantouBtnjiada];
           
                

                
                
                UIButton*addressImage = [[UIButton alloc]init];
                addressImage.frame = CGRectMake(ScreenWidth/2+40,105,20, 20);
                [addressImage setImage:[UIImage imageNamed:@"daohangsss"] forState:UIControlStateNormal];
                [view1 addSubview:addressImage];
                UILabel*address=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/2, 90, ScreenWidth/2, 50)];
                address.text=[NSString stringWithFormat:@"%@", @"    去那里"];
                address.textColor=shenhuicolor;
                address.textAlignment=NSTextAlignmentCenter;
                address.font=[UIFont systemFontOfSize:15];
                [view1 addSubview:address];
                UIButton*jiantouBtnjiada1 = [[UIButton alloc]init];
                jiantouBtnjiada1.frame = CGRectMake(ScreenWidth/2,90,ScreenWidth/2, 50);
                [jiantouBtnjiada1 addTarget:self action:@selector(shanghubuttonimage:) forControlEvents:UIControlEventTouchUpInside];
                jiantouBtnjiada1.tag=302;
                [view1 addSubview:jiantouBtnjiada1];
                

                
                
                UILabel*xiangqing=[[UILabel alloc]initWithFrame:CGRectMake(15, diseview1.bottom, 100, 45)];
                xiangqing.text=@"活动详情";
                xiangqing.textColor=[UIColor blackColor];
                xiangqing.font=[UIFont systemFontOfSize:15];
                [view addSubview:xiangqing];
                
                UIImageView *_xianview1 = [[UIImageView alloc]initWithFrame:CGRectMake(15,xiangqing.bottom, ScreenWidth-30, 0.5)];
                _xianview1.image=[UIImage imageNamed:@"hengxian"];
                [view addSubview:_xianview1];

                NSString *s12 = [NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"actDetail"]];
                UIFont *font12 = [UIFont systemFontOfSize:15];
                CGSize size12 = CGSizeMake(ScreenWidth-30, 2000);
                CGSize labelsize12 = [s12 sizeWithFont:font12 constrainedToSize:size12 lineBreakMode:NSLineBreakByCharWrapping];
            
                UILabel*details2=[[UILabel alloc]initWithFrame:CGRectMake(15, xiangqing.bottom+25, ScreenWidth-30, labelsize12.height)];
                details2.text=[NSString stringWithFormat:@"%@", [severDataDict.dataDict objectForKey:@"actDetail"]];
                details2.textColor=shenhuicolor;
                details2.numberOfLines=0;
                details2.font=[UIFont systemFontOfSize:15];
                [view addSubview:details2];
                
                view.frame=CGRectMake(0, 210, ScreenWidth, details2.bottom);
                [mainScroll setContentSize:CGSizeMake(ScreenWidth, view.bottom+64)];

       
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    gonggaoarry=[[NSArray alloc]init];
    
    
    
    
    
    
}


-(void)editor:(UIButton*)sender{
    
    editorActViewController *detailViewController = [[editorActViewController alloc] init];
    [self.navigationController pushViewController:detailViewController animated:YES];
    
    
    
}


-(void)closeKeyBoad
{
    [fengxiangview removeFromSuperview];
    [fengxiangScroll removeFromSuperview];
    [quxiao removeFromSuperview];
}
-(void)fenxiangss:(UIButton*)sender{
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:@"coupon" forKey:@"contentType"];
    [param setValue:commdity.actTypeCode forKey:@"contentId"];
    [param setValue:@"wx_single" forKey:@"shareTarget"];
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    
    
    [HttpRequest requestData:@"Company/getShareUrl" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                self.shuoming=[severDataDict.dataDict objectForKey:@"shareDescription"];
                self.shareUrl=[severDataDict.dataDict objectForKey:@"shareUrl"];
                
                fengxiangview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
                fengxiangview.backgroundColor=[UIColor blackColor];
                fengxiangview.alpha=0.5;
                [self.view addSubview:fengxiangview];
                
                fengxiangScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,ScreenHeight-240, ScreenWidth,200)];
                fengxiangScroll.delegate = self;
                fengxiangScroll.userInteractionEnabled = YES;
                fengxiangScroll.scrollEnabled = YES;
                fengxiangScroll.showsVerticalScrollIndicator = FALSE;
                fengxiangScroll.showsHorizontalScrollIndicator = FALSE;
                fengxiangScroll.backgroundColor=[UIColor whiteColor];
                [self .view addSubview:fengxiangScroll];
                
                // 手势
                UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
                singleFingerOne.numberOfTouchesRequired = 1; //手指数
                singleFingerOne.numberOfTapsRequired = 1; //tap次数
                singleFingerOne.delegate = self;
                [fengxiangview addGestureRecognizer:singleFingerOne];
                
                
                
                
                NSArray*nameBtn=[[NSArray alloc]initWithObjects:@"发送給朋友",@"分享到朋友圈",nil];
                NSArray *arrayimage = @[@"faweixin",@"fenxiangpenyouquan"];
                for (int i = 0; i<2; i++) {
                    UIButton *nameButcenter = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3*i,   80*ScreenHeight/1334+15, ScreenWidth/3, 60)];
                    
                    [fengxiangScroll addSubview:nameButcenter];
                    
                    
                    UIButton *nameBut = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3*i,   nameButcenter.bottom+20, ScreenWidth/3, 14)];
                    [nameBut setTitle: [nameBtn objectAtIndex:i]  forState:UIControlStateNormal];
                    nameBut.tag=201+i;
                    [nameBut setTitleColor:shenhuicolor forState:0];
                    nameBut.titleLabel.font=[UIFont systemFontOfSize:14];
                    [nameBut addTarget:self action:@selector(fengxiang:) forControlEvents:UIControlEventTouchUpInside];
                    [fengxiangScroll addSubview:nameBut];
                    
                    
                    UIButton *wuyebuttonimage = [UIButton buttonWithType:UIButtonTypeCustom];
                    wuyebuttonimage.frame = CGRectMake(ScreenWidth/3*i,  10, 60, 60);
                    
                    wuyebuttonimage.tag = 201+i;
                    wuyebuttonimage.center=nameButcenter.center;
                    [wuyebuttonimage setImage:[UIImage imageNamed: [arrayimage objectAtIndex:i]] forState:UIControlStateNormal];
                    [wuyebuttonimage addTarget:self action:@selector(fengxiang:) forControlEvents:UIControlEventTouchUpInside];
                    [fengxiangScroll addSubview:wuyebuttonimage];
                    
                    
                }
                
                
                quxiao = [[UIButton alloc] initWithFrame:CGRectMake(0,ScreenHeight-45,  ScreenWidth, 45)];
                [quxiao setTitle:@"取消" forState:UIControlStateNormal];
                quxiao.titleLabel.font=[UIFont systemFontOfSize:16];
                quxiao.backgroundColor=[UIColor whiteColor];
                [quxiao setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                [quxiao addTarget:self action:@selector(closeKeyBoad) forControlEvents:UIControlEventTouchUpInside];
                [self .view addSubview:quxiao];
                UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, ScreenWidth-30, 0.35)];
                line.backgroundColor=qianhuicolor;
                [quxiao addSubview:line];
                
                
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    
    
}






-(void)fengxiang:(UIButton*)sender{
    [fengxiangview removeFromSuperview];
    [fengxiangScroll removeFromSuperview];
    [quxiao removeFromSuperview];
    NSURL *url = [NSURL URLWithString:[commdity.Dict objectForKey:@"imageUrlFull"]];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *image1 = [[UIImage alloc] initWithData:data];
    if (sender.tag==201) {
        if (![[commdity.Dict objectForKey:@"actDetail"]isEqualToString:@""]) {
            self.shuoming=[commdity.Dict objectForKey:@"actDetail"];
        }

        [UMSocialData defaultData].extConfig.wechatSessionData.title =[commdity.Dict objectForKey:@"actName"];
        UMSocialUrlResource *urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeDefault url:self.shareUrl];
        
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatSession].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
        [UMSocialData defaultData].extConfig.wechatSessionData.url = self.shareUrl;
        [[UMSocialDataService defaultDataService]postSNSWithTypes:@[UMShareToWechatSession] content:self.shuoming image:image1 location:nil urlResource:urlResource presentedController:self completion:^(UMSocialResponseEntity *response){
            
            if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
            }
            
        }];
        
        
        
        
        
        
    }
    
    if (sender.tag==202) {
        
        
        UMSocialUrlResource *urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeDefault url:self.shareUrl];
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatTimeline].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
        [UMSocialData defaultData].extConfig.wechatTimelineData.url = self.shareUrl;
        [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatTimeline] content:[NSString stringWithFormat:@"%@",  [commdity.Dict objectForKey:@"actName"]] image:image1 location:nil urlResource:urlResource presentedController:self completion:^(UMSocialResponseEntity *response){
            if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
            }
        }];
        
        
        
        
    }
    
}
-(NSString *) getImageFromURLs:(NSString *)imageUrl {
    
    
    
    NSString * results;
    
    
    [imageUrlarrays addObject:imageUrl];
    
    
    commdity.imageUrls=imageUrlarrays;
     NSLog(@"aaaaaaaa---%@",commdity.imageUrls);
    return results;
    
}

-(UIImage *) getImageFromURL:(NSString *)fileURL {
    
    
    UIImage * result;
    
    
    
    NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:fileURL]];
    
    result = [UIImage imageWithData:data];
    
    [imagearrays addObject:result];
   
    
    commdity.imageUrlFullarr=imagearrays;
    return result;
    
}


- (void)timerFireMethod:(NSTimer *)timer

{
    
    NSCalendar *calendar = [NSCalendar currentCalendar];
    
    
    NSString* string = commdity.endDate;
    NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
    [dateFormatter1 setDateFormat: @"yyyy-MM-dd HH:mm:ss"];
    NSDate *destDate= [dateFormatter1 dateFromString:string];
    
    
    unsigned int unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
    
    NSDateComponents *d = [calendar components:unitFlags fromDate: [NSDate date] toDate:destDate options:0];//计算时间差
    
    
    NSString* string2 = commdity.endDate;
    NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc] init];
    [dateFormatter2 setDateFormat: @"yyyy-MM-dd HH:mm:ss"];
    NSDate *destDate2= [dateFormatter2 dateFromString:string2];
    NSTimeInterval  timeInterval2 = [destDate2 timeIntervalSinceDate:[NSDate date]];
    

      if ([d day] <=0) {
          
          
          if ([d month] <=0) {
              timeLabel.text = [NSString stringWithFormat:@"剩%@天%ld小时   %ld分%ld秒",@"0", (long)[d hour], (long)[d minute], (long)[d second]];
              
              timeLabel.textColor = [UIColor colorWithRed:204.0/255.0 green:3.0/255.0 blue:2.0/255.0 alpha:1.0];
              
              NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"剩%@天%ld小时   %ld分%ld秒",@"0", (long)[d hour], (long)[d minute], (long)[d second]]];
              
              [AttributedStr addAttribute:NSFontAttributeName
               
                                    value:[UIFont systemFontOfSize:14]
               
                                    range:NSMakeRange(0, 9)];
              
              [AttributedStr addAttribute:NSForegroundColorAttributeName
               
                                    value:shenhuicolor
               
                                    range:NSMakeRange(0, 9)];
              
              
              timeLabel.attributedText = AttributedStr;
          }
          
          if ([d second] <0) {
              timeLabel.text=@"已结束";
              
          }
          
         

          
      }else{
    
    if ([d month] <=0) {
        timeLabel.text = [NSString stringWithFormat:@"剩%ld天%ld小时   %ld分%ld秒", (long)[d day], (long)[d hour], (long)[d minute], (long)[d second]];
    }
    
    if ([d second] <0) {
        timeLabel.text=commdity.endDate;

    }

    timeLabel.textColor = [UIColor colorWithRed:204.0/255.0 green:3.0/255.0 blue:2.0/255.0 alpha:1.0];
    
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"剩%.0f天%ld小时   %ld分%ld秒",timeInterval2/60/60/24-1, (long)[d hour], (long)[d minute], (long)[d second]]];
    
    [AttributedStr addAttribute:NSFontAttributeName
     
                          value:[UIFont systemFontOfSize:14]
     
                          range:NSMakeRange(0, 9)];
    
    [AttributedStr addAttribute:NSForegroundColorAttributeName
     
                          value:shenhuicolor
     
                          range:NSMakeRange(0, 9)];
    
    
    timeLabel.attributedText = AttributedStr;
    
      }
    
}


- (void)shanghubuttonimage:(UIButton *)button{
    if (button.tag==301) {
        
        
        
        [ACETelPrompt callPhoneNumber: [[commdity.Dict objectForKey:@"companyBaseInfo"] objectForKey:@"phone"]
                                 call:^(NSTimeInterval duration) {
                                     NSLog(@"User made a call of %.1f seconds", duration);
                                     
                                 } cancel:^{
                                     NSLog(@"User cancelled the call");
                                 }];
        
        
        
        
        
    }
    if (button.tag==302) {
        
        
        [self address];
        
        
        
    }
    
    if (button.tag==303) {
        
        
        
        
        
        
    }
    
}

-(void)address{
    
    
    NSString *oreillyAddress =commdity.adress;
    
    CLGeocoder *myGeocoder = [[CLGeocoder alloc] init];
    [myGeocoder geocodeAddressString:oreillyAddress completionHandler:^(NSArray *placemarks, NSError *error) {
        if ([placemarks count] > 0 && error == nil) {
            
            CLPlacemark *firstPlacemark = [placemarks objectAtIndex:0];
            double latitude=firstPlacemark.location.coordinate.longitude;
            NSString *latitudeString=[NSString stringWithFormat:@"%f",latitude];
            double longitude=firstPlacemark.location.coordinate.latitude;
            NSString *longitudeString=[NSString stringWithFormat:@"%f",longitude];
            NSLog(@"latitudeString= %@", longitudeString);
            NSLog(@"longitudeString= %@",latitudeString);
            NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
                                        commdity.adress,@"address",
                                        commdity.adress,@"city",
                                        @"google",@"from_map_type",
                                        commdity.adress,@"region", nil];
            
            [dic setValue:longitudeString forKey:@"google_lat"];
            [dic setValue:latitudeString forKey:@"google_lng"];
            
            NSLog(@"latitudeString= %@", longitudeString);
            NSLog(@"longitudeString= %@",latitudeString);
            
            
            MapViewControllers* h=[[MapViewControllers alloc] init];
            h.navDic=dic;
            h.mapType = RegionNavi;
            [self.navigationController pushViewController:h animated:YES];
            
            
            
        }
        else if ([placemarks count] == 0 && error == nil) {
            NSLog(@"Found no placemarks.");
        }
        else if (error != nil) {
            NSLog(@"An error occurred = %@", error); }
    }];
    
    
    
}


-(void)shangping:(UIButton*)sender{
    
    
    [self sea1:[NSString stringWithFormat:@"%@",sender.titleLabel.text]];
    
}

- (void)sea1:(NSString *)String{
    //[self.data startAnimating];
    
    
    commdity.itemId=String;
    
    GetProductDetailViewController*vc1=[[GetProductDetailViewController alloc] init];
    
    [self.navigationController pushViewController:vc1 animated:YES];
    
    
}




-(void)commodity:(UIButton*)sender{
    
    
    [self sea:[NSString stringWithFormat:@"%@",sender.titleLabel.text]];
    
}

- (void)sea:(NSString *)String{

    commdity.caseID=String;
    
    CaseDetailViewController*vc1=[[CaseDetailViewController alloc] init];
    
    [self.navigationController pushViewController:vc1 animated:YES];
    
    
}
-(void)lijibaoming:(UIButton*)sender{
    
//    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
//    NSString* Token = [user objectForKey:@"tokenId"];
//    if (Token ==nil) {
//        Token=@"dd";
//    }
//    NSMutableDictionary *param = [NSMutableDictionary new];
//    [param setValue:Token forKey:@"tokenId"];
//    [param setValue: @"F" forKey:@"dataType"];
//    [param setValue: @"20" forKey:@"pageSize"];
//    [param setValue: @"1" forKey:@"pageIndex"];
//    
//    NSLog(@"====%@",param);
//    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
//    
//    
//    [HttpRequest requestData:@"Business/Act/List" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
//        if (isSuccess) {
//            
//            NSLog(@"====%@",severDataDict.dataDict);
//            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
//                [Global hideProgressHUDInternal:self.view];
//       
//                                   NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
//                                  [Global showTextHud:requestResultStr view:self.view];
//
//            
//            
//            }
//            
//            
//            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
//                    
//                
//                    
//                    TheLoginViewController *detailViewController = [[TheLoginViewController alloc] init];
//                    [self.navigationController pushViewController:detailViewController animated:YES];
//                
//            }
//            
//        }
//        else
//        {
//            [Global hideProgressHUDInternal:self.view];
//            
//            [Global showTextHudSub:@"连接失败" view:self.view];
//        }
//        
//    }];

       
}



- (CGFloat)_initWithframe:(CGRect )frame title:(NSString *)title quanbutitle:(NSString *)quanbutitle number:(NSInteger)number{
    //线
    UIImageView *line = [[UIImageView alloc]initWithFrame:frame];
    line.backgroundColor = LineColor;
    [mainScroll addSubview:line];
    //蓝色小点
    
    
    UILabel *quan = [[UILabel alloc]initWithFrame:CGRectMake(10, line.bottom+14, 15, 15)];
    quan.textColor = luseColor;
    quan.text=@"o";
    quan.font=[UIFont boldSystemFontOfSize:15];
    [mainScroll addSubview:quan];
    
    
    UILabel *label_title = [[UILabel alloc]initWithFrame:CGRectMake(25, line.bottom, 80, 45)];
    label_title.text = title;
    label_title.font=[UIFont systemFontOfSize:15];
    [mainScroll addSubview:label_title];
    UILabel *label_quanbutitle = [[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-150, line.bottom, 120, 45)];
    label_quanbutitle.textColor=zhonghuiColor;
    label_quanbutitle.text = quanbutitle;
    label_quanbutitle.textAlignment=NSTextAlignmentRight;
    label_quanbutitle.font=[UIFont systemFontOfSize:15];
    [mainScroll addSubview:label_quanbutitle];
    
    UIButton*jiantouBtnjiada = [[UIButton alloc]init];
    jiantouBtnjiada.frame = CGRectMake(ScreenWidth-120,line.bottom,145, 45);
    [jiantouBtnjiada addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    jiantouBtnjiada.tag=number;
    [mainScroll addSubview:jiantouBtnjiada];
    UIButton*jiantouBtn = [[UIButton alloc]init];
    jiantouBtn.frame = CGRectMake(ScreenWidth-20,line.bottom+16,8, 13);
    [jiantouBtn setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
    [jiantouBtn addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    jiantouBtn.tag=number;
    [mainScroll addSubview:jiantouBtn];
    
    UIImageView *_xianview = [[UIImageView alloc]initWithFrame:CGRectMake(10,label_title.bottom-0.5, ScreenWidth-20, 0.5)];
    _xianview.image=[UIImage imageNamed:@"hengxian"];
    
    [mainScroll addSubview:_xianview];
    
    return label_title.bottom;
}




- (void)buttonAction:(UIButton *)button{
    
    
    switch (button.tag)
    {
        case 1:
            
            if (button.tag==1) {
                
                [addView removeFromSuperview];
                
                myJobViewController*de = [[myJobViewController alloc] init];
                
                [self.navigationController pushViewController:de animated:YES];
                
                
            }
            break;
            
        case 2:
            
            if (button.tag==2) {
                
                [addView removeFromSuperview];
                
                
                
                ActListViewController*de = [[ActListViewController alloc] init];
                
                [self.navigationController pushViewController:de animated:YES];
                
                
            }
            
            break;
            
        case 3:
            if (button.tag==3) {
                [addView removeFromSuperview];
                
                
                GetProductListViewController*de = [[GetProductListViewController alloc] init];
                
                [self.navigationController pushViewController:de animated:YES];
                
                
            }
            
            break;
        case 4:
            if (button.tag==4) {
                [addView removeFromSuperview];
                
                
                CaseListViewController*de = [[CaseListViewController alloc] init];
                
                [self.navigationController pushViewController:de animated:YES];
                
                
            }
            
            break;
            
        default:
            break;
    }
}








- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}
@end